package hcb.dms;


import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;



public class TestActivity extends TabActivity
{
    private TabHost mTabHost = null;
    private Intent mIntent = null;
    private TabHost.TabSpec mTabSpec = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        initializeTabs();
    }

    private void initializeTabs() {
        mTabHost = getTabHost();
        mIntent = new Intent().setClass(this, Tab1.class);
        mTabSpec = mTabHost.newTabSpec("Tab1").setIndicator("Tab1",getResources().getDrawable(R.drawable.ic_launcher)).setContent(mIntent);
        mTabHost.addTab(mTabSpec);

        mIntent = new Intent().setClass(this, Tab2.class);
        mTabSpec = mTabHost.newTabSpec("Tab2").setIndicator("Tab2",getResources().getDrawable(R.drawable.ic_launcher)).setContent(mIntent);
        mTabHost.addTab(mTabSpec);

        mTabHost.setCurrentTab(0);
    }

    public class Tab1 extends TabActivity
    {
        private TabHost mTabHost = null;
        private Intent mIntent = null;
        private TabHost.TabSpec mTabSpec = null;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.tab1);
            initializeTabs();
        }

        private void initializeTabs() {
            mTabHost = getTabHost();
            mIntent = new Intent().setClass(this, Tab2.class);

            mTabSpec = mTabHost
                    .newTabSpec("Tab1 Child 1")
                    .setIndicator("Tab1 Child 1",
                            getResources().getDrawable(R.drawable.ic_launcher))
                    .setContent(mIntent);
            mTabHost.addTab(mTabSpec);

            mIntent = new Intent().setClass(this, Tab2.class);
            mTabSpec = mTabHost
                    .newTabSpec("Tab1 Child 2")
                    .setIndicator("Tab1 Child 2",
                            getResources().getDrawable(R.drawable.ic_launcher))
                    .setContent(mIntent);
            mTabHost.addTab(mTabSpec);
            mTabHost.setCurrentTab(0);
        }
    }

    public class Tab2 extends TabActivity
    {
        private TabHost mTabHost = null;
        private Intent mIntent = null;
        private TabHost.TabSpec mTabSpec = null;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.tab2);
            initializeTabs();
        }

        private void initializeTabs() {
            mTabHost = getTabHost();
            mIntent = new Intent().setClass(this, Tab1.class);

            mTabSpec = mTabHost
                    .newTabSpec("Tab2 Child 1")
                    .setIndicator("Tab2 Child 1",
                            getResources().getDrawable(R.drawable.ic_launcher))
                    .setContent(mIntent);
            mTabHost.addTab(mTabSpec);

            mIntent = new Intent().setClass(this, Tab1.class);
            mTabSpec = mTabHost
                    .newTabSpec("Tab2 Child 2")
                    .setIndicator("Tab2 Child 2",
                            getResources().getDrawable(R.drawable.ic_launcher))
                    .setContent(mIntent);
            mTabHost.addTab(mTabSpec);
            mTabHost.setCurrentTab(1);
        }
    }
}